package forms;

import java.util.Date;

import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Digits;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;

import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.SafeHtml;
import org.hibernate.validator.constraints.SafeHtml.WhiteListType;
import org.springframework.format.annotation.DateTimeFormat;

import domain.Painting;


public class PaintingForm {

	// Constructors

	public PaintingForm() {
		super();
	
	}
	public PaintingForm(Painting painting) {
		super();
		this.setId(painting.getId());
		this.setAppraisal(painting.getAppraisal());
		this.setAuthor(painting.getAuthor());
		this.setDate(painting.getDate());
		this.setTitle(painting.getTitle());
	
	}
	
	// Attributes
	private int id;
	private String title;
	private String author;
	private double appraisal;
	private Date date;
	
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}
	
	@NotNull
	@NotBlank
	@SafeHtml( whitelistType = WhiteListType.NONE )
	public String getTitle() {
		return title;
	}
	
	public void setTitle(String title) {
		this.title = title;
	}
	
	@NotNull
	@NotBlank
	@SafeHtml( whitelistType = WhiteListType.NONE )
	public String getAuthor() {
		return author;
	}
	
	public void setAuthor(String author) {
		this.author = author;
	}
	
	@Min(0)
	@Digits(integer=4, fraction=2)
	public double getAppraisal() {
		return appraisal;
	}
	public void setAppraisal(double appraisal) {
		this.appraisal = appraisal;
	}
	
	@NotNull
	@Past
	@Temporal(TemporalType.TIMESTAMP)
	@DateTimeFormat(pattern = "yyyy/MM/dd HH:mm")
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	
	//Relationship
	

	
}
